<!--推广-->
<template>
  <div class="storePromotion">
    <div class="spinner" v-if="$store.state.loadingFlag">
      <div class="spinner-container container1">
        <div class="circle1"></div>
        <div class="circle2"></div>
        <div class="circle3"></div>
        <div class="circle4"></div>
      </div>
      <div class="spinner-container container2">
        <div class="circle1"></div>
        <div class="circle2"></div>
        <div class="circle3"></div>
        <div class="circle4"></div>
      </div>
      <div class="spinner-container container3">
        <div class="circle1"></div>
        <div class="circle2"></div>
        <div class="circle3"></div>
        <div class="circle4"></div>
      </div>
    </div>
      <el-row class="top"><el-col :span="24"><span>推广列表</span></el-col></el-row>
       <div class="menu">
       <el-row class="menu-content" >
         <el-col  :span="screenWidth>1200?8:10" style="padding-left: 35px;">
           <div>
             <span style="width: 150px;display: inline-block;text-align: right;">商家名称／联系电话:</span>
             <el-input class="menu_input menu-label" v-model="input" style="width: 40%;"></el-input>
           </div>
           <div class="menu-bottom ">
             <span  style="width: 150px;display: inline-block;text-align: right;">申请项目:</span>
             <el-input class="menu_input" v-model="projectDesc" style="width: 40%;"></el-input>
           </div>
         </el-col>
          <el-col :span="8" style="padding-left: 35px;">
            <div>
              <span>申请状态:</span>
              <el-select class="menu-select" placeholder="全部" v-model="status" @visible-change="selectChange">
                <el-option
                  v-for="item in promotionStatus"
                  :key="item.value"
                  :label="item.typeName"
                  :value="item.typeId">
                </el-option>
              </el-select>
            </div>
            <div class="menu-bottom">
              <el-button class="comfirmBtn" @click="reSet">重置</el-button>
              <el-button class="comfirmBtn" @click="queryPromoteList">查询</el-button>
            </div>
          </el-col>
          <el-col :span="screenWidth>1200?8:6" style="padding-left: 35px;">
            <div>
              <span>项目类型:</span>
              <el-select class="menu-select" placeholder="全部" v-model="projectType" :style="screenWidth>1200?'width: 40%;':'width: 50%;'">
                <el-option
                  v-for="item in projectDesc1"
                  :key="item.value"
                  :label="item.typeName"
                  :value="item.type">
                </el-option>
              </el-select>
              <!--<el-input class="menu_input" style="width: 40%;" v-model="projectType"></el-input>-->
            </div>
          </el-col>
        </el-row>
       </div>

    <div class="content" style="margin:20px 20px 0 20px;">
      <el-row class="c_title">
        <el-col :span="3"><span>商家名称</span></el-col>
        <el-col :span="2"><span>姓名</span></el-col>
        <el-col :span="3"><span>联系方式</span></el-col>
        <el-col :span="2"><span>项目类型</span></el-col>
        <el-col :span="3"><span>申请项目</span></el-col>
        <el-col :span="2"><span>申请状态</span></el-col>
        <el-col :span="3"><span>受理纪录</span></el-col>
        <el-col :span="3"><span>申请日期</span></el-col>
        <el-col :span="3"><span>操作</span></el-col>
      </el-row>
      <div class="c-margin" :style="screenWidth<1367?'height:70%':'height:90%'" >
        <el-row class="c-list font_size1 font_color1 " v-for="(item,index) in promotionList" :key="index"
                :style="index%2==0?'background-color: rgba(236,238,242,1);border-radius: 5px;':'border-radius: 5px;'">
          <el-col :span="3"><span>{{item.storeName}}</span></el-col>
          <el-col :span="2"><span>{{item.contactName?item.contactName:'???'}}</span></el-col>
          <el-col :span="3"><span>{{item.phone}}</span></el-col>
          <el-col :span="2"><span>{{item.projectDesc}}</span></el-col>
          <el-col :span="3"><span>{{item.itemsDesc}}</span></el-col>
          <el-col :span="2">
            <span v-if="item.state==10">申请中</span>
            <span v-if="item.state==20">已受理</span>
            <span v-if="item.state==30">已上线</span>
            <span v-if="item.state==40">已到期</span>
            <span v-if="item.state==50">已取消</span>
          </el-col>
          <el-col :span="3" class="oh_"><span>{{item.comment?item.comment:'&nbsp;'}}</span></el-col>
          <el-col :span="3"><span>{{item.createTime}}</span></el-col>
          <el-col :span="3"><span class="font_color3" @click="promote(item)" style="cursor: pointer;">更改状态</span></el-col>
        </el-row>
      </div>
    </div>

    <!--更改状态弹框-->
    <div class="mask" v-if="statusModuleShow1"></div>
    <div class="statusModule" v-if="statusModuleShow">
      <div class="status">
        <span class="s_name">更改状态：</span>
        <div class="s_right">
          <el-radio-group v-model="radio2" class="s_radio">
            <el-radio :label="item.typeId" v-if="index<3" v-for="(item,index) in promotionStatus">{{item.typeName}}</el-radio>
          </el-radio-group>
          <el-radio-group v-model="radio2" class="s_radio">
            <el-radio :label="item.typeId" v-if="index>=3" v-for="(item,index) in promotionStatus">{{item.typeName}}</el-radio>
          </el-radio-group>
        </div>
      </div>
      <div class="record">
        <span>纪录受理情况:</span>
        <el-input type="textarea" :rows="5" v-model="textarea"></el-input>
      </div>
      <div class="btn">
        <el-button class="cancleBtn qx_btn" @click="dialogVisibleF">取消</el-button>
        <el-button class="comfirmBtn" @click="promoteSave">确定</el-button>
      </div>
    </div>
    <el-dialog style="text-align: center;position: absolute;" :visible.sync="dialogVisible" size="tiny" :modal="false" :close-on-click-modal="false">
      <span style="font-size: 14px;color: rgba(89,115,128,1)">{{dialogData}}</span>
      <span slot="footer" class="dialog-footer">
                  <el-button @click="dialogVisibleF" class="cp_qx" >确 定</el-button>

                </span>
    </el-dialog>
      <div class="block">
        <el-pagination
          style="float: right;"
          @current-change="handleCurrentChange"
          :current-page.sync="currentPage"
          layout=" prev, pager, next"
          :total="pageTotal*10">
        </el-pagination>
        <div style="float: right;">
          <span style="margin-top: 5px;display: inline-block">共 {{pageTotal}} 页</span>
          <span style="margin-left: 20px;margin-top: 10px;">共计{{sumNumber}}条</span>
        </div>
      </div>

  </div>
</template>
<script type="text/ecmascript-6">
  export default {
    data(){
      return {
        screenWidth: document.body.clientWidth,
        dialogVisible:false,
        dialogData:false,
        statusModuleShow1:false,
        statusModuleShow:false,
        pageTotal:0,
        sumNumber:0,
        currentPage:0,
        input:"",
        projectDesc:"",
        projectType:"",
        status:"",
        value:"",
        page:0,
        textarea:"",
        promoteData:"",
        Delivery_state:[
          {type:0,typeId:"0",value:"全部"},
          {type:1,typeId:"1",value:"待投放"},
          {type:2,typeId:"2",value:"投放中"},
          {type:3,typeId:"3",value:"已下架"},
          {type:3,typeId:"4",value:"已过期"},
          {type:3,typeId:"5",value:"已领完"},
        ],
        promotionList:[

        ],
        projectDesc1:[
          {type:0,typeName:"全部"},
          {type:1,typeName:"小程序"},
          {type:2 ,typeName:"公众号"},
        ],
        radio2:"",
        promotionStatus:[
//          {type:0,typeId:0,typeName:"全部"},
          {type:1,typeId:"10",typeName:"申请中"},
          {type:2,typeId:"20",typeName:"已受理"},
          {type:3,typeId:"30",typeName:"已上线"},
          {type:4,typeId:"40",typeName:"已到期"},
          {type:5,typeId:"50",typeName:"已取消"},
        ],
      }
    },
    mounted () {
      const that = this
      window.onresize = () => {
        return (() => {
          window.screenWidth = document.body.clientWidth
          that.screenWidth = window.screenWidth
        })()
      }
    },
    watch:{
      radio2(val){
      },
      screenWidth (val) {
        this.screenWidth = val
      },
      dialogVisible(val){
          if(!val&&!this.statusModuleShow){
            this.statusModuleShow1 = false
          }
      },
      input(val,oldVal){
        if(oldVal&&val.length == 0){
          this.queryPromoteList()
        }
      },
      projectDesc(val,oldVal){
        if(oldVal&&val.length == 0){
          this.queryPromoteList()
        }
      },
    },
    methods: {
      //页码
      handleCurrentChange(val) {
      this.page = val-1
       this.queryPromoteList()
      },
      selectChange(val){
        if(val){
          if(this.promotionStatus[0].typeName!='全部'){
            this.promotionStatus.unshift({type:0,typeId:0,typeName:"全部"})
          }
        }
      },
      dialogVisibleF(){
          this.dialogVisible =   this.statusModuleShow1 = this.statusModuleShow =  false
      },
      reSet(){
        this.input = this.status = this.projectType=  this.projectDesc=``
      },
      promote(item){
        if(this.promotionStatus[0].typeName=='全部')   this.promotionStatus.shift()
        this.status = ''
        this.statusModuleShow = true
        this.statusModuleShow1 = true
        this.promoteData = item
        this.radio2 =this.promoteData.state+""
        this.textarea = this.promoteData.comment
      },
      promoteSave(){
//          ?page=0&size=&state=&content=&prj=&item=
        let path = ``
        if(!this.radio2) {
          this.dialogVisible = true
          this.dialogData = `请选择更改状态`
          return
        }
        if(!this.textarea)  this.textarea=``
        path+=`?comment=${this.textarea}`
        this.$http.put(`${this.$store.state.path}promote/state/${this.promoteData.promoteId}/${this.radio2}${path}`)//查询小区商户
          .then(res => {
          this.statusModuleShow = false
          this.statusModuleShow1 = false
         this.queryPromoteList()
      }, res => {

        })
      },
      queryPromoteList(){
        this.radio2 = ""
        this.textarea = ""
        let path = ``
        if(this.input) path+=`&content=${this.input}`
        if(this.projectDesc) path+=`&itemDesc=${this.projectDesc}`
        if(this.projectType&&this.projectType>0) path+=`&prj=${this.projectType}`
        if(this.status) path+=`&state=${this.status}`
        this.$store.state.loadingFlag = true
        this.promotionList = []
        this.$http.get(`${this.$store.state.path}promote/list/${this.$store.state.storeId}?page=${this.page}&size=10${path}`)//查询小区商户
          .then(res => {
        this.$store.state.loadingFlag = false
        if(res.body.result){
          this.promotionList = res.body.result.pageList
          this.pageTotal = res.body.result.totalPage
          this.sumNumber = res.body.result.sumNumber
        }
        if(!res.body.result){
          this.promotionList = []
          this.pageTotal = 0
          this.sumNumber = 0
        }
      }, res => {

        })
      }
    },
    created(){
      this.queryPromoteList();
    }
  }
</script>
<style scoped>
  .font_color1{
    color:#597380;
  }
  .font_color2{
    color:#fff;
  }
  .font_color3{
    color:#FF8761;
  }
  .font_size1{
    font-size:14px;
  }
  .oh_{
    white-space: nowrap;  /*强制span不换行*/
    /*display: inline-block;  !*将span当做块级元素对待*!*/
    overflow: hidden;  /*超出宽度部分隐藏*/
    text-overflow: ellipsis;  /*超出部分以点号代替*/
  }
  .el-button{
    background-color:#57BDDE;
    border: 1px solid #57BDDE;
    color: #fff;
  }
  .font_size2{
    font-size:16px;
  }
  .font_size3{
    font-size:18px;
  }
  .bgcolor1{
    background-color:#fff;
  }
  .bgcolor2{
    background-color:#57BDDE;
  }
  .bgcolor3{
    background-color:#ECEEF2;
  }
  .menu{
    /*border:1px solid blue;*/
    margin:20px 20px 0 20px!important;
  }
 .menu .menu-content{
   color:#597380;
   font-size:14px;
   background-color:#fff;
  }
  .storePromotion{
    background-color:#F5F5F5;
    padding-left:200px;
  }
  .storePromotion .top{
    height:70px;
    line-height:70px;
    background-color:#fff;
    color:#597380;
    font-size:18px;
    border-bottom:1px solid #D7D9DD;
  }
  .storePromotion .top span{
    display:inline-block;
    width:150px;
    height:100%;
    line-height:70px;
    text-align:center;
    font-size:18px;
    font-family: MicrosoftYaHei;
    float: left;
    border-right:1px solid #D7D9DD;
  }
  .storePromotion .content{
    height:58%;
    border-radius:5px;
    border: 1px solid rgba(4, 4, 4, 0.09);
    border-bottom: 2px solid rgba(4, 4, 4, 0.09);
    background-color:#fff;
  }
  .storePromotion .content .c_title{
    width: 100%;
    height:50px;
    line-height:50px;
    text-align:center;
    padding:0 13px;
    border-radius:5px;
    background-color:#57BDDE;
    color:#fff;
    font-size:14px;
  }
  .storePromotion .content .c-margin{
    padding:14px 13px;
    height:50%;
    overflow: auto;
    width: 100%;
  }
  .storePromotion .content .c-list{
    /*height:40px;*/
    line-height:40px;
    text-align:center;
    font-size:12px;
  }
  .storePromotion  .mask{
    background:rgba(0,0,0,0.7);
    position:fixed;
    left:0;
    top:0;
    width:100%;
    height:100%;
    z-index:999;
  }
  .storePromotion  .statusModule{
    position:fixed;
    left:50%;
    top:50%;
    transform: translate(-50%,-50%);
    width:490px;
    height:390px;
    background:rgba(255,255,255,1);
    z-index:1000;
    border-radius:5px;
    padding:38px 78px 37px 78px;
  }
  .statusModule .status{
    position:relative;
  }
  .statusModule .status .s_name{
    float:left;
    width:83px;
    position:absolute;
    top:0;
    left:0;
  }
  .statusModule .status .s_right{
     float:left;
  }
  .statusModule .status .s_radio{
    margin-left:83px;
    margin-bottom:15px;
  }
  .statusModule .record{
    margin-top:94px;
  }
  .statusModule .record span{
    display:inline-block;
    margin-bottom:12px;
  }
  .statusModule .btn{
    margin-top:28px;
  }

</style>
